/*
 * @Date: 2019-06-09 11:37:19
 * @Author: Ryan Huang
 * @Description:
 */
package main

import (
	"fmt"
	"reflect"
)

func main() {
	str0 := "1234567890"
	fmt.Println([]rune(str0)[8])
	str1 := "0.189"
	var strInterface = reflect.ValueOf(str1).Interface()
	fmt.Printf("参数类型是%T \n", strInterface)
	fmt.Println(isNumberic(str1))
}

func isNumberic(v interface{}) bool {
	switch v.(type) {
	case string:
		str := v.(string)
		var pointCount int
		for key, item := range str {
			if item == 46 && (key == 0 || key == len(str)-1) {
				return false
			}
			if item < 46 || item == 47 || item > 57 {
				return false
			}
			if item == 46 {
				pointCount++
				if pointCount > 1 {
					return false
				}
			}
		}
		return true
	case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
		return true
	case float32, float64, complex64, complex128:
		return true
	}
	return false
}
